package com.stone.business.gzrwd.action;

/**
 * <pre>
 * 变电运行工区工作任务单 
 * @author
 * </pre>
 */

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpSession;

import com.stone.business.gzrwd.pojo.TGzrwd;
import com.stone.business.gzrwd.service.ZbjlCommonService;
import com.stone.para.IConstant;
import com.stone.utils.StringUtils;

import frm.ssh.action.BaseListAction;

public class GzrwdWpListAction extends BaseListAction {

	private static final long serialVersionUID = 3979577965804736350L;

	private ZbjlCommonService myService;
	
	public ZbjlCommonService getMyService() {
		return myService;
	}

	public void setMyService(ZbjlCommonService myService) {
		this.service = myService;
		this.myService = myService;
	}
	
    /** * 构造方法. */
    public GzrwdWpListAction() {
        this.entityClass = TGzrwd.class;
    }
private Long planid;
	public Long getPlanid() {
	return planid;
}

public void setPlanid(Long planid) {
	this.planid = planid;
}

	/**
	 * 设置查询条件
	 *//*
	public HashMap<String, Object> setSearchCondition() {
		
		HashMap<String, Object> m = new HashMap<String, Object>();
		
		List<Object> valsList = new ArrayList<Object>();
		
//		String organCode = String.valueOf(super.getSession().getAttribute(IConstant.SESSION_TORGAN_CODE));

		String organCode = String.valueOf(super.getSession().getAttribute(IConstant.SESSION_TORGAN_CODE));
	//	String isLike = String.valueOf(super.getSession().getAttribute(IConstant.SESSION_ISLIKE));
		
		String isLike ="like";
		m.put("cols", "new map(s.id as id, s.rq as rq,s.pcsj as pcsj, s.bh as bh, zbzname as zbzname, zbyname as zbyname, s.ycclqk as gzfw, case when bgzr='21' then '保护班' when bgzr='22' then '检修班' when bgzr='23' then '变压器班' when bgzr='24' then '试验班' else '' end as bzname,s.czkssj as czkssj,s.czjssj as czjssj,s.bdzname as bdzname,s.sfwc as sfwc)");
		
//		// 查询条件OUID很重要
//		String conditions = " s.ouid like '" + organCode + "%'";
	String conditions = " state = '" + super.getSearchBean().getCon1() + "'"; 
//		 查询条件OUID很重要
		//String conditions = " s.ouid "+isLike+" '" + organCode + "%'";
		//String conditions += " and state = '" + super.getSearchBean().getCon1() + "'";
		
		// 巡视时间
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon2())) {
			conditions += " AND TO_CHAR(s.rq,'yyyy-MM-dd') >= ?";
			valsList.add(super.getSearchBean().getCon2());
		}
		
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon3())) {
			conditions += " AND TO_CHAR(s.rq,'yyyy-MM-dd') <= ?";
			valsList.add(super.getSearchBean().getCon3());
		}
		
		// 变电站
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon4())) {
			conditions += " AND s.sfwc = ?";
			valsList.add(super.getSearchBean().getCon4());
		}
		// 工作计划下的任务单
		if (planid!=null) {
			conditions += " AND s.planid = ?";
			valsList.add(planid);
		}
		// 查询条件
		m.put("conditions",conditions);
		m.put("clause", " order by s.czkssj Desc");
		m.put("alias", "s");//, TOrgan o
		m.put("vals", valsList.toArray());
		
	//	DictionaryService dicService = (DictionaryService) SpringUtil.getInstance().getBean("dicService");
	//	xslxList = dicService.findList("XSLX");
		HttpSession session= super.getSession();
		return m;
		
	}*/
/**
 * 设置查询条件
 */
public HashMap<String, Object> setSearchCondition() {
	
	HashMap<String, Object> m = new HashMap<String, Object>();
	
	List<Object> valsList = new ArrayList<Object>();
	StringBuffer sql = new StringBuffer();
	sql.append(" select s.id as id,");
	sql.append("	 s.rq as rq,s.pcsj as pcsj, s.bh as bh, zbzname as zbzname, zbyname as zbyname, s.cxch as cxch,s.gs as gs,s.ycclqk as gzfw,(select t.organ_name from sys_organ t where t.id=s.bgzr) as bzname,TO_CHAR(s.czkssj,'YYYY-MM-DD HH24:MI') as czkssj,TO_CHAR(s.czjssj,'YYYY-MM-DD HH24:MI') as czjssj,s.bdzname as bdzname,s.sfwc as sfwc,s.wcqk as wcqk,s.ylwt as ylwt ");
	sql.append("	from TAB_GZRWD s ");
	String conditions = " where s.state = '" + super.getSearchBean().getCon1() + "'"; 
	// 实际结束日期
	if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon2())) {
		conditions += " AND TO_CHAR(s.rq,'yyyy-MM-dd') >= ?";
		valsList.add(super.getSearchBean().getCon2());
	}
	
	if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon3())) {
		conditions += " AND TO_CHAR(s.rq,'yyyy-MM-dd') <= ?";
		valsList.add(super.getSearchBean().getCon3());
	}
	
	// 是否完成
	if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon4())) {
		conditions += " AND s.sfwc = ?";
		valsList.add(super.getSearchBean().getCon4());
	}
	// 当日明日
	if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon5())) {
		
		if(super.getSearchBean().getCon5().equals("01")){
			conditions += " AND TO_CHAR(s.rq,'yyyy-MM-dd') = TO_CHAR(sysdate,'yyyy-MM-dd')";
		}else{
			conditions += " AND TO_CHAR(s.rq,'yyyy-MM-dd') = TO_CHAR(sysdate+1,'yyyy-MM-dd')";
		}
		
	}
	// 工作计划下的任务单
	if (planid!=null) {
		conditions += " AND s.planid = ?";
		valsList.add(planid);
	}
	m.put("vals", valsList.toArray());
	m.put("pageflag", "sql");
	m.put("sql", sql.toString() + conditions + "  order by s.rq Desc");
	
	return m;
	
}

}
